package util;

import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;

/**
 * Used for checking if a string is pure ASCII (required for FTP username).
 * Inspired by: http://stackoverflow.com/questions/3585053/in-java-is-it-possible-to-check-if-a-string-is-only-ascii
 * @author ernesta
 */
public class StringUtils {
    static CharsetEncoder asciiEncoder = Charset.forName("US-ASCII").newEncoder();
    
    public static boolean isPureAscii(String string) {
        return asciiEncoder.canEncode(string);
    }
}